#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int ret = 0;
    vector<int> tmp;
    int subsetXORSum(vector<int>& nums) {
        tmp.push_back(0);
        dfs(nums, 0);
        return ret;
    }

    void dfs(vector<int>& nums, int i)
    {

        if (i == nums.size())
        {
            return;
        }
        for (int j = i; j < nums.size(); ++j)
        {
            int xOr = (nums[j] ^ tmp.back());
            ret += xOr;
            tmp.push_back(xOr);
            dfs(nums, j + 1);
            tmp.pop_back();
        }

    }

};